package com.example.myenglish;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.content.res.AssetManager;

public class CopyDB {
public void copy(AssetManager assetManager) {
		
		File f=new File("/data/data/com.example.myenglish/databases");
		if(!f.exists()){
				f.mkdir();
		}
		File db = new File("/data/data/com.example.myenglish/databases/TLCN.sqlite");
		if (!db.exists()) {
			InputStream inputStream = null;
			FileOutputStream fileOutputStream = null;
			
			try {
				inputStream = assetManager.open("TLCN.sqlite");
				byte[] buffer = new byte[inputStream.available()];
				inputStream.read(buffer);
	
				fileOutputStream = new FileOutputStream(db);
				fileOutputStream.write(buffer);
	
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally {
				try {
					inputStream.close();
					fileOutputStream.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	
			}
		}
	}
}
